import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;

public class Solution3 {
    public int[] smallestK(int[] nums, int k){
        int[] ret = new int[k];
        Queue<Integer> heap = new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1 - o2;
            }
        });
        for(int i = 0; i < nums.length; i++){
            heap.offer(nums[i]);
        }
        for(int i = 0; i < k; i++){
            ret[i] = heap.poll();
        }
        return ret;
    }
}
